package com.example.controller;


import com.example.model.User;
import org.springframework.web.bind.annotation.*;

/**
 * 方法注解
 */
@RestController
@RequestMapping("/method")
public class MethodController {

    @GetMapping("/people/{pid}/animal/{aid}")
    public String method(@PathVariable String pid,
                         @PathVariable("aid") String animalId){
        return "用户id: "+pid+",动物id: "+animalId;
    }

    @RequestMapping("/getname")
    public String method2(String name){
        return "姓名："+name;
    }

    @RequestMapping("/login")
    public String method3(@RequestBody String name, @RequestBody String password){
        return "姓名："+name+", 密码："+password;
    }

    @RequestMapping("/reg")
    public String method4(@RequestParam String name, @RequestParam String password){
        return "姓名："+name+", 密码："+password;
    }

    @RequestMapping("/reg2")
    public String method5(String username, String password, String img){
        return "username："+username+", password："+password+"img："+img;
    }

    @RequestMapping("/reg3")
    public String method6(@RequestParam User user){
        return "username："+user.getUsername()+
                ", password："+user.getPassword()+
                ", img："+user.getPhoto();
    }
}
